# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Ali H. Caliskan <ali.h.caliskan AT gmail DOT com>
# Contributor: Ryan Coyner <rcoyner@gmail.com>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>

pkgname=mixxx
pkgver=2.3.4
pkgrel=2
pkgdesc="Free, open source software for digital DJing"
arch=(loong64 x86_64)
url="https://www.mixxx.org"
license=(GPL2)
groups=(pro-audio)
# TODO: package libshout-idjc
depends=(
  gcc-libs
  glibc
  hidapi
  lame
  libglvnd
  libmad
  libmodplug
  libx11
  openssl
  opusfile
  qt5-base
  qt5-script
  qt5-svg
  qt5-x11extras
  qtkeychain
  soundtouch
  speex
  sqlite
  taglib
  upower
  wavpack
)
makedepends=(
  chromaprint
  cmake
  faad2
  ffmpeg
  fftw
  flac
  glib2
  glu
  gperftools
  libid3tag
  libogg
  libsndfile
  libusb
  libvorbis
  lilv
  lv2
  qt5-tools
  portaudio
  portmidi
  protobuf
  rubberband
  vamp-plugin-sdk
)
checkdepends=(xorg-server-xvfb)
source=(https://github.com/${pkgname}dj/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('75f5c1c6eb887072f0faa31bd469b79f5d03ea6df9174a8743adb2d8811f229c8f16d0d28931fe4810760af17376d254252500ff5825dcf21b20d03e763a78c9')
b2sums=('4d5ae391cdc3b2bd2502665e60d3bcd8749deff54ebbbda1716803e0cfe496bc2ef5adc02500f9553a338221c7484ade9fc2e6ec7a23057affe93e49b2bcfe51')

build() {
  local cmake_options=(
    -B build
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX=/usr
    -S $pkgname-$pkgver
    -Wno-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  xvfb-run ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    chromaprint libchromaprint.so
    flac libFLAC.so
    ffmpeg libavcodec.so libavformat.so libavutil.so
    fftw libfftw3.so
    glib2 libgobject-2.0.so
    libid3tag libid3tag.so
    libogg libogg.so
    libsndfile libsndfile.so
    libusb libusb-1.0.so
    libvorbis libvorbis.so libvorbisenc.so libvorbisfile.so
    lilv liblilv-0.so
    portaudio libportaudio.so
    portmidi libportmidi.so
    protobuf libprotobuf-lite.so
    rubberband librubberband.so
  )

  DESTDIR="$pkgdir" cmake --install build
}
